package com.yztc.orangeentertainment.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.yztc.orangeentertainment.R;
import com.yztc.orangeentertainment.bean.channalbean.ArticleBean;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by My on 2016/10/6.
 */
public class MyChannalContentHSAdapter extends RecyclerView.Adapter<MyChannalContentHSAdapter.MyViewHolder> {
    private List<ArticleBean> list;
    private Context context;

    public MyChannalContentHSAdapter(List<ArticleBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(context).inflate(R.layout
                .channal_rvhead_item, parent,false));
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, int position) {
        Glide.with(context).load(list.get(position).getPic()).into(holder.ivChannalrvheaditem);
        holder.tvChannalrvheaditemtitle.setText(list.get(position).getTitle());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        @InjectView(R.id.iv_channalrvheaditem)
        ImageView ivChannalrvheaditem;
        @InjectView(R.id.tv_channalrvheaditemtitle)
        TextView tvChannalrvheaditemtitle;

        public MyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.inject(this, itemView);
        }
    }
}
